package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Train;
import com.example.Laboratory.Service.TrainService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@Api(value = "Train", description = "大创成果")
@RestController
@RequestMapping(value = "/Train")
@CrossOrigin
public class TrainController {

    @Autowired
    TrainService trainService;

    @ApiOperation(value = "添加大创成果信息", notes = "添加大创成果信息")
    @RequestMapping(value = "/addTrain", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addTrain (Train i) throws IOException {
        return ResultCode.SUCCESS.result(trainService.addTrain(i));
    }

    @ApiOperation(value = "删除大创成果信息", notes = "删除大创成果信息")
    @RequestMapping(value = "/deleteTrain", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteTrain (@RequestParam int train_id) throws IOException {
        return ResultCode.SUCCESS.result(trainService.deleteTrain(train_id));
    }

    @ApiOperation(value = "查找大创成果信息", notes = "查找大创成果信息")
    @RequestMapping(value = "/researchTrain", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchTrain ( ) throws IOException {
        return ResultCode.SUCCESS.result(trainService.researchTrain());
    }

    @ApiOperation(value = "修改大创成果信息", notes = "修改大创成果信息")
    @RequestMapping(value = "/reviseTrain", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseTrain (Train i) throws IOException {
        return ResultCode.SUCCESS.result(trainService.reviseTrain(i));
    }
}
